package org.bulu.project.system.service.impl.per;

import org.bulu.project.common.result.Result;
import org.bulu.project.system.mapper.VideoMapper;
import org.bulu.project.system.mapper.VideoStatsMapper;
import org.bulu.project.system.model.entity.Video;
import org.bulu.project.system.model.entity.VideoStats;
import org.bulu.project.system.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

@Service
public class VideoServiceImpl implements VideoService{

    @Autowired
    private VideoMapper videoMapper;

    @Autowired
    private VideoStatsMapper videoStatsMapper;
    @Override
    public List<Video> getVideosByIds(Long uid) {
        return videoMapper.getVideosByIds(uid);
    }

    @Override
    public Video getVideoWithDataById(Integer vid) {
        try{
            return videoMapper.findVideoById(vid);
        }catch (Exception e){
            throw new RuntimeException("查询视频信息时出现异常");
        }
    }

    @Override
    public int delVideo(Integer vid) throws IOException {
        return videoMapper.delVideo(vid);
    }

    @Override
    public int updateVideo(Video video) throws IOException {
        return videoMapper.updateVideo(video);
    }

    @Override
    public List<Video> getVideosWithDataByIdList(List<Integer> list) {
        return List.of();
    }

    @Override
    public Result updateVideoStatus(Integer vid, Integer status) throws IOException {
        return null;
    }

    @Override
    public VideoStats getVideoStats(Integer vid) {
       try{
           return videoStatsMapper.queryById(vid);
       }catch (Exception e){
           throw new RuntimeException("查询视频Status信息时出现异常");
       }
    }
}
